
                <section class="row">
                    <div class="col-12">
                        <div>
                            <h1><?= $template['title'] ?></h1>
                        </div>
                        <div>
                            <?= $this->breadcrumb->output(); ?>
                        </div>
                    </div>
                </section>

                <section class="row">
                    <div class="col-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h2 class="panel-title"><?= $template['title'] ?></h3>
                            </div>
                            <div class="panel-body form-container">
                                <?php if(isset($template['partials']['notifications'])) echo $template['partials']['notifications']; ?>
                                <form id="role-form" method="post" action="<?= base_url() ?>roles/<?= $action ?>" class="form-bordered form-horizontal">
                                    <fieldset>
                                        <legend><?= $template['title'] ?></legend>
                                        <ul>
                                            <li class="form-group row{name-status}">
                                                <label for="name" class="control-label col-3">
                                                    Name *
                                                    <br><small>(Alphanumeric Characters)</small>
                                                </label>
                                                <div class="control-group input-center col-9">
                                                    <div class="input-size col-12">
                                                        <div class="input-group">
                                                            <span class="input-group-addon"><i class="fa fa-edit"></i></span>
                                                            <input type="text" name="name" id="name" class="form-control" placeholder="Role Name" value="<?= $name ?>">
                                                        </div>
                                                        <?= form_error('name') ?>
                                                    </div>
                                                </div>
                                            </li>
                                            <li class="form-group row{description-status}">
                                                <label for="description" class="control-label col-3">
                                                    Description
                                                    <br><small>(Long Text)</small>
                                                </label>
                                                <div class="control-group col-9">
                                                    <div class="input-size">
                                                        <textarea name="description" id="description" class="form-control" placeholder="Role Description..."><?= $description ?></textarea>
                                                        <?= form_error('description') ?>
                                                    </div>
                                                </div>
                                            </li>

                                            <li class="form-group row{name-status}">
                                                <label for="view" class="control-label col-3">
                                                    Role Permissions *
                                                    <br><small>(Alphanumeric Characters)</small>
                                                </label>
                                                <div class="control-group input-center col-9">
                                                    <div class="input-size col-6">
                                                        
                                                        <table class="table table-hover table-bordered table-responsive">
                                                            <thead>
                                                                <tr>
                                                                    <th class="align-center script_show"><input type="checkbox" name="toggle_all" id="toggle_all" class="toggle"></th>
                                                                    <th>Module Name</th>
                                                                    <?php foreach($permission_set as $permission_title) : ?>
                                                                    <th class="align-center"><?= $permission_title ?></th>
                                                                    <?php endforeach ; ?>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php
                                                                    foreach($modules as $module) :
                                                                    $module_name            = isset($module['name']) ? strtolower( str_replace(' ', '_', $module['name']) ) : '';
                                                                    $module_permissions     = isset($module['permissions']) ? unserialize($module['permissions']) : '';
                                                                ?>
                                                                <tr>
                                                                    <td class="align-center script_show"><input type="checkbox" name="<?= $module_name ?>" id="<?= $module_name ?>" class="toggle toggle-all"></td>
                                                                    <td><label for="<?= $module_name ?>"><?= $module['name'] ?></label></td>
                                                                    
                                                                    <?php foreach($permission_set as $permission) {
                                                                        $permission = changeCase( $permission, 'human_upper' );
                                                                        $module_permission = in_array($permission, $module_permissions) ? $permission : 'N/A';
                                                                    ?>
                                                                        <td class="align-center">
                                                                            <?php if( $module_permission === 'N/A' ) : ?>
                                                                            N/A
                                                                            <?php else : ?>
                                                                            <input type="checkbox" name="permissions[<?= $module['id'] ?>][<?= $permission ?>]" class="toggle-all <?= $module_name ?>">
                                                                            <?php endif; ?>
                                                                        </td>
                                                                    <?php } ?>
                                                                </tr>
                                                                <?php endforeach; ?>
                                                            </tbody>
                                                        </table>
                                                        
                                                    </div>
                                                </div>
                                            </li>
                                            
                                            <?php if ($add) : ?>
                                            <li class="form-group row">
                                                <label for="add-another" class="control-label col-3">
                                                    Add Another
                                                    <br><small>(Clear Form After Add)</small>
                                                </label>
                                                <div class="control-group col-9">
                                                    <div class="input-size">
                                                        <div class="checkbox">
                                                            <label class="control-label">
                                                                <input type="checkbox" name="add-another" id="add-another" value="yes"<?= $add_another ?>> 
                                                                <small>Do Not Redirect.</small>
                                                            </label>
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                            <?php endif; ?>
                                            
                                        </ul>
                                    </fieldset>

                                    
                                    <div class="submit-group col-12 align-right">
                                        <input type="hidden" name="id" id="id" value="<?= $id ?>">
                                        <input type="submit" name="submit" class="btn btn-primary" value="Save">
                                        <a href="<?= base_url() ?>roles" class="btn btn-default">Cancel</a>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </section>